<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>上传组图</title>
<meta name="keywords" content=''>
<meta name="description" content=''>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="__STATIC__/css/base.css">
<link rel="stylesheet" href="__STATIC__/css/qb_ui.css">
<link rel="stylesheet" href="__STATIC__/icon/icon.css">
<script type="text/javascript" src="__STATIC__/js/core/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC__/layer/layer.js"></script>
</head>
<body>

<link rel="stylesheet" href="__STATIC__/index/default/header.css">
<div class="qb_ui_wap_nav">
	<a href='#' class="home"><i class="si si-home"></i>上传图片</a>

</div> 
<link rel="stylesheet" href="__STATIC__/bbs/post.css">
<div class="bbsContainer">

	<div class="PostBox">
		<ul class="uploadImg">
		    <div style="display:none;">
				<input type="file" name="fileToUpload" id="fileToUpload" accept="image/*" multiple/>
				<input type="text" name="picurl" value="{$img}" id="compressValue"  style="width:100%;" /> 
			</div>
			<ol>点击下面图标上传图片</ol>
			<li onclick='$("#fileToUpload").click()'><i class="si si-camera"></i></li>
		</ul>
		<div class="ListImgs"></div>
				<div class="button"><button type="butotn" onclick="save_pic()">全部上传完毕,确认保存</button></div>		
	</div>

</div>

<script type="text/javascript" src="__STATIC__/js/base64uppic.js"></script>
<script type="text/javascript">

function save_pic(){
	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    parent.layer.close(index);
	parent.end_upfile_images($("#compressValue").val());
}

		var severUrl = "{:urls('index/attachment/upload')}?dir=images&from=base64&module=index";
		var pics = [];
        //图片上传change事件
        $('#fileToUpload').change(function(){			
            uploadBtnChange($(this).attr("id"),'compressValue',pics,viewpics);
        });

		function viewpics(url,pic_array){
			var html = '';
			pic_array.forEach(function(f){
				html += '<div><span><img src="/public/'+f+'"></span><em><i class="fa fa-remove"></i></em></div>';
			});
			$(".ListImgs").html(html);
			addclick();
		}

		if($("#compressValue").val()!='')pics = $("#compressValue").val().split(',');
		viewpics('',pics);		
		

		function addclick(){
			$(".ListImgs em").click(function(e){
				//这里删除的图片没有真正从服务器删除
				$(this).parent().remove();
				pics = [];
				var obj = $(".ListImgs img");
				obj.each(function(e){
					var img = $(this).attr("src");
					img = img.replace('/public/','');
					pics.push(img);
					$("#compressValue").val( pics.join(',') );
				});
				if(obj.length==0){
					$("#compressValue").val('');
				}			
			});
		}
		addclick();

 
</script>
</body>
</html>